import request from '@/utils/request'
import axios from 'axios'

export function getToken() {
  return 'Bearer ' + JSON.parse(localStorage.getItem('jxtoken'))
}

const baseURL = process.env.VUE_APP_API_BASE_URL

/**
 * 上传文件
 */
export function uploadChunk(data) {
  return request({
    url: '/questionBank/file/upload/uploadChunk',
    method: 'post',
    data
  })
}

/**
 * 合并文件
 */
export function mergeFile(data) {
  return axios({
    url: `${baseURL}/questionBank/file/upload/mergeChunks`,
    method: 'post',
    data,
    headers: {
      jxtoken: getToken()
    }
  })
}

/**
 * 上传小文件
 */
export function uploadSmallFile(data) {
  return request({
    url: '/questionBank/file/upload/smallFile',
    method: 'post',
    data
  })
}